package com.snailct.bpp.commons.utils;


import org.aspectj.lang.annotation.AfterReturning;
import org.aspectj.lang.annotation.Aspect;
import org.aspectj.lang.annotation.Before;
import org.aspectj.lang.annotation.Pointcut;

import java.lang.reflect.Method;

/**
 * Created by huangxa on 2016/6/23.
 */
@Aspect
public class DBConnectionMonitor{
    @Pointcut("execution(* org.apache.commons.dbcp2.PoolingDataSource.*(..))")
    private void anyMethod(){};//定义切入点
    @Before("anyMethod()")
    public void checkConnection(){
        System.out.println("开始获取数据连接");
    }
    @AfterReturning("anyMethod()")
    public void closeConnection(){
        System.out.println("获取数据连接成功");
    }

}
